
from config import base_config
import uvicorn

from common.log import logger
from models import init_db


if __name__ == "__main__":
    init_db() 
    logger.info("[服务器] 🚀 启动服务器...")
    try:
        uvicorn.run(
            "service.main_app:app",  # 更新模块路径
            host=base_config.SERVER_HOST,
            port=base_config.SERVER_PORT,
            reload=True,
            reload_dirs=["./"]  # 指定监控当前目录
        )
    except KeyboardInterrupt:
        logger.info("[服务器] 👋 服务器已关闭，再见~")
    except Exception as e:
        logger.error(f"[服务器] ❌ 启动服务器时发生错误: {e}")
